package com.syg.logback.core;

import com.syg.boot.util.net.NetUtil;
import com.syg.logback.consts.LogTypeEnum;

import java.io.Serializable;

/**
 * @author syg
 * @version 1.0
 * @date 2021年11月24日19:14:46
 */
public class SqlLogInf implements Serializable {

    private static final long serialVersionUID = -8094354545792169603L;
    private String sqlId;
    private String sqlName;
    private String sqlClassPath;
    private String sqlMethod;
    private String sqlCommandType;
    private String datasourceType;
    private String sql;
    private long exeTm;
    private String exeIp;
    private String exeSts = "S";
    private String sqlParamJson;
    private String respCode;
    private String respMsg;

    public SqlLogInf(String sqlId, String sqlCommandType, String datasourceType, String sql, long exeTm) {
        this.sqlId = sqlId;
        this.sqlCommandType = sqlCommandType;
        this.datasourceType = datasourceType;
        this.sql = sql;
        this.exeTm = exeTm;
        this.exeIp = NetUtil.getLocalHostIp();
    }

    public SqlLogInf(SqlLogInfBuilder builder) {
        this.sqlId = builder.getSqlId();
        this.sqlName = builder.getSqlName();
        this.sqlClassPath = builder.getSqlClassPath();
        this.sqlMethod = builder.getSqlMethod();
        this.sqlCommandType = builder.getSqlCommandType();
        this.datasourceType = builder.getDatasourceType();
        this.sql = builder.getSql();
        this.sqlParamJson = builder.getSqlParamJson();
        this.exeTm = builder.getExeTm();
        this.exeSts = builder.getExeSts();
        this.respCode = builder.getRespCode();
        this.respMsg = builder.getRespMsg();
        this.exeIp = NetUtil.getLocalHostIp();
    }

    @Override
    public String toString() {
        return LogTypeEnum.SQL + "@@@" + this.sqlCommandType + "#@%@#" + this.sqlName + "#@%@#" + this.datasourceType + "#@%@#" + this.sqlClassPath + "#@%@#" + this.sqlMethod + "#@%@#" + this.sqlId + "#@%@#" + this.sql + "#@%@#" + this.sqlParamJson + "#@%@#" + this.exeIp + "#@%@#" + this.exeTm + "#@%@#" + this.exeSts + "#@%@#" + this.respCode + "#@%@#" + this.respMsg;
    }

    public void setSqlId(String sqlId) {
        this.sqlId = sqlId;
    }

    public void setSqlName(String sqlName) {
        this.sqlName = sqlName;
    }

    public void setSqlClassPath(String sqlClassPath) {
        this.sqlClassPath = sqlClassPath;
    }

    public void setSqlMethod(String sqlMethod) {
        this.sqlMethod = sqlMethod;
    }

    public void setSqlCommandType(String sqlCommandType) {
        this.sqlCommandType = sqlCommandType;
    }

    public void setDatasourceType(String datasourceType) {
        this.datasourceType = datasourceType;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public void setExeTm(long exeTm) {
        this.exeTm = exeTm;
    }

    public void setExeIp(String exeIp) {
        this.exeIp = exeIp;
    }

    public void setExeSts(String exeSts) {
        this.exeSts = exeSts;
    }

    public void setSqlParamJson(String sqlParamJson) {
        this.sqlParamJson = sqlParamJson;
    }

    public void setRespCode(String respCode) {
        this.respCode = respCode;
    }

    public void setRespMsg(String respMsg) {
        this.respMsg = respMsg;
    }

    public String getSqlId() {
        return this.sqlId;
    }

    public String getSqlName() {
        return this.sqlName;
    }

    public String getSqlClassPath() {
        return this.sqlClassPath;
    }

    public String getSqlMethod() {
        return this.sqlMethod;
    }

    public String getSqlCommandType() {
        return this.sqlCommandType;
    }

    public String getDatasourceType() {
        return this.datasourceType;
    }

    public String getSql() {
        return this.sql;
    }

    public long getExeTm() {
        return this.exeTm;
    }

    public String getExeIp() {
        return this.exeIp;
    }

    public String getExeSts() {
        return this.exeSts;
    }

    public String getSqlParamJson() {
        return this.sqlParamJson;
    }

    public String getRespCode() {
        return this.respCode;
    }

    public String getRespMsg() {
        return this.respMsg;
    }
}
